import adata

## github https://github.com/1nchaos/adata

# 获取所有股票代码
#           stock_code short_name exchange   list_date
# 0        000001       平安银行       SZ  1991-04-03
# 1        000002        万科Ａ       SZ  1991-01-29
def get_all_stock_code():
    res_df = adata.stock.info.all_code()
    return res_df

# 获取股票的行情
# 获取到股票代码后，传入对应的stock_code参数，查询对应股票的行情信息
# k_type: k线类型：1.日；2.周；3.月 默认：1 日k
def get_stock_info(stock_code, k_type=1, start_date=None):
    res_df = adata.stock.info.stock_info(stock_code, k_type, start_date)
    return res_df

# 获取单只股票的股本信息，来源：东方财富网
def get_stock_capital_info(stock_code):
    res_df = adata.stock.info.get_stock_shares(stock_code)
    return res_df

# 获取单只股票的申万一二级行业
def get_stock_industry_info(stock_code):
    res_df = adata.stock.info.get_industry_sw(stock_code)
    return res_df

# 所有A股概念代码信息（同花顺）
def get_all_concept_info():
    res_df = adata.stock.info.all_concept_code_ths()
    return res_df

# 获取股票交易日信息
# 当年
def get_stock_trade_date():
    res_df = adata.stock.info.trade_calendar()
    return res_df

# 获取单只股票的分红信息
def get_stock_dividend_info(stock_code):
    res_df = adata.stock.market.get_dividend(stock_code)
    return res_df

# 获取单只股票的行情信息-日、周、月 k线
# stock_code: 股票代码
# k_type: : k线类型：1.日；2.周；3.月,4季度，5.5min，15.15min，30.30min，60.60min 默认：1 日k
# start_date: 开始日期
# end_date: 结束日期
# adjust_type: 复权类型：K线复权类型：0.不复权；1.前复权；2.后复权 默认：1 前复权 （目前：只有前复权,作为股票交易已经可用）
def get_stock_kline_info(stock_code, k_type=1, start_date=None,end_date=None,adjust_type =1):
    res_df = adata.stock.market.get_market(stock_code,start_date,end_date, k_type, adjust_type)
    return res_df

# 获取单个股票的今日分时行情	只能获取当天
def get_market_min(stock_codes): # 股票代码列表
    res_df = adata.stock.market.get_market_min(stock_codes)
    return res_df

# 获取多个股票最新行情信息 
def get_market_info(stock_codes): # 股票代码列表
    res_df = adata.stock.market.list_market_current(stock_codes)
    return res_df

# 获取单个股票的5档行情信息
def get_market_tick(stock_code): # 股票代码
    res_df = adata.stock.market.get_market_five(stock_code)
    return res_df

# 获取单个股票的分笔成交行情
def get_market_tick_detail(stock_code): # 股票代码  
    res_df = adata.stock.market.get_market_bar(stock_code)
    return res_df

# 获取单个概念的行情信息-日、周、月 k线
# concept_code: 同花顺概念指数代码
# k_type: k线类型：1.日；2.周；3.月 默认：1 日k
# adjust_type: k线复权类型：0.不复权；1.前复权；2.后复权 默认：1 前复权
def get_concept_kline_info(concept_code, k_type=1, adjust_type =1):
    res_df = adata.stock.market.get_market_concept_ths(concept_code,k_type, adjust_type)
    return res_df

# 获取单个概念的行情信息-日、周、月 k线
# 获取东方财富概念行情时，
# 指数代码BK开头，index_code
# :param index_code: 东方财富概念指数代码：BK开头
# :param k_type: k线类型：1.日；2.周；3.月 默认：1 日k
# :return: k线行情数据 [日期，开，高，低，收,成交量，成交额]
def get_concept_kline_info_eastmoney(concept_code, k_type=1):
    res_df = adata.stock.market.get_market_concept_east(concept_code,k_type)
    return res_df


# 获取同花顺概念行情-当日分时	只能获取当天
def get_concept_min_info(concept_code):
    res_df = adata.stock.market.get_market_concept_min_east(concept_code)
    return res_df

# 获取同花顺当前的概念行情	实时行情
def get_concept_current_info(concept_code):
    res_df = adata.stock.market.get_market_concept_current_east(concept_code)
    return res_df

# 获取指数的行情信息-日、周、月 k线
def get_index_kline_info(index_code, k_type=1,start_date=None):
    res_df = adata.stock.market.get_market_index(index_code,k_type, start_date)
    return res_df

# 获取指数的行情-当日分时
def get_index_min_info(index_code):
    res_df = adata.stock.market.get_market_index_min(index_code)
    return res_df

# 获取当前的指数行情	实时行情
def get_index_current_info(index_code):
    res_df = adata.stock.market.get_market_index_current(index_code)
    return res_df

# 获取单个股票的今日分时资金流向	最新实时数据
def get_capital_flow_min_info(stock_code):
    res_df = adata.stock.market.get_capital_flow_min(stock_code)
    return res_df

# 获取单个股票的资金流向	历史日度数据
def get_capital_flow_info(stock_code,start_date=None,end_date=None):
    res_df = adata.stock.market.get_capital_flow(stock_code,start_date,end_date)
    return res_df

# 获取所有东财概念近N日资金流向	获取近1,5,10日资金流向
def get_all_capital_flow_info(concept_code):
    res_df = adata.stock.market.all_capital_flow_east(concept_code)
    return res_df

## 热度榜单
# 获取东方财富热度榜单
def get_eastmoney_hot_list():
    res_df = adata.sentiment.hot.pop_rank_100_east()
    return res_df

# 获取同花顺热度榜单
def get_ths_hot_list():
    res_df = adata.sentiment.hot.hot_rank_100_ths()
    return res_df

# 同花顺热门概念板块20排行榜
def get_ths_hot_concept_list():
    res_df = adata.sentiment.hot.hot_concept_20_ths()
    return res_df

# 龙虎榜单列表
def get_longhu_list():
    res_df = adata.sentiment.hot.list_a_list_daily()
    return res_df

# 单只股票龙虎榜信息详情
def get_stock_longhu_info(stock_code):
    res_df = adata.sentiment.hot.get_a_list_info(stock_code)
    return res_df

